package com.view.mediator
{
	import com.model.proxy.ComponentStateProxy;
	import com.view.component.ThreeView;

	import flash.events.Event;

	import org.puremvc.as3.multicore.interfaces.IMediator;
	import org.puremvc.as3.multicore.patterns.mediator.Mediator;

	public class ThreeViewMediator extends Mediator implements IMediator
	{
		public static const NAME:String='ThreeViewMediator';
		private var componentStateProxy:ComponentStateProxy;

		public function ThreeViewMediator(viewComponent:Object)
		{
			super(NAME, viewComponent);
		}

		protected function get threeView():ThreeView
		{
			return viewComponent as ThreeView;
		}

		override public function onRegister():void
		{
			threeView.labelText=NAME + " wrote this.";
			threeView.addEventListener(ThreeView.SWITCH_STATES, onSwitchStates);
			componentStateProxy=facade.retrieveProxy(ComponentStateProxy.NAME) as ComponentStateProxy;
		}

		protected function onSwitchStates(event:Event):void
		{
			componentStateProxy.switchTo=threeView.chosenState;
			sendNotification(MainViewMediator.STATES_SWITCHER, "FourView");
		}
	}
}